<%@ page pageEncoding="UTF-8"%>
<%@ include file="../common/global.jsp"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="../common/meta.jsp"%>
<title><f:message key="common.title" /> - <f:message key="user" /></title>
<%@ include file="../common/css.jsp"%>
</head>
<body>
<div id="wrapper">

<%@ include file="../common/topbar.jsp" %>
<%@ include file="../common/header.jsp" %>

<div id="masthead">

    <div class="container">

        <div class="masthead-pad">

            <div class="masthead-text">

            </div> <!-- /.masthead-text -->

        </div>

    </div> <!-- /.container -->

</div> <!-- /#masthead -->

<div id="content">

<div class="container">

<div class="row">

<div class="tabbable">

    <div class="span3">

        <ul class="nav nav-tabs nav-stacked">
            <li class="active">
                <a href="#tab1" data-toggle="tab">
                    <i class="icon-ok"></i>
                    <f:message key="user.edit_user"/>
                    <i class="icon-chevron-right"></i>
                </a>
            </li>

            <li>
                <a href="#tab2" data-toggle="tab">
                    <i class="icon-user"></i>
                    <f:message key="user.create_user"/>
                    <i class="icon-chevron-right"></i>
                </a>
            </li>


        </ul>

    </div> <!-- /.span3 -->

    <div class="span9">

        <div class="tab-content">

            <div class="tab-pane active" id="tab1">

                <h2><f:message key="user.edit_user" /></h2>

                <br />

                <form id="edit-user_edit_form" class="form-horizontal">
                    <fieldset>
                        <div class="control-group">
                            <input type="hidden" id="id" value="${user.id}">
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="username"><f:message key="user.username"/></label>
                            <div class="controls">
                                <input type="text" class="input-medium disabled" id="username" value="${user.username}" disabled="">
                                <p class="help-block"></p>
                            </div> <!-- /controls -->
                        </div> <!-- /control-group -->


                        <div class="control-group">
                            <label class="control-label" for="password1"><f:message key="user.password"/></label>
                            <div class="controls">
                                <input type="password" class="input-medium" id="password1" >
                            </div> <!-- /controls -->
                        </div> <!-- /control-group -->

                        <div class="form-actions">
                            <button type="submit" class="btn btn-primary btn-large"><f:message key="common.save" /></button>
                            <button class="btn btn-large" id="back" ><f:message key="common.back" /></button>
                        </div> <!-- /form-actions -->
                    </fieldset>
                </form>

            </div> <!-- /#tab1 -->


        </div> <!-- /.tab-content -->

    </div> <!-- /.span9 -->

</div> <!-- /.tabbable -->

</div> <!-- /.row -->


</div> <!-- /.container -->

</div> <!-- /#content -->

</div> <!-- /#wrapper -->

<%@ include file="../common/footer.jsp"%>
<%@ include file="../common/js.jsp"%>

<script type="text/javascript">
    $(function() {
        $('#user_edit_form').ajaxForm({
            type: 'put',
            url: BASE + '/user/' + $('#id').val(),
            dataType: 'json',
            beforeSubmit: function() {
                return Smart.Validator.checkRequired('user_edit_form');
            },
            success: function(result) {
                if (result.success) {
                    location.href = BASE + '/users';
                }
            }
        });

        $('#save').click(function() {
            $('#user_edit_form').submit();
        });

        $('#back').click(function() {
            location.href = BASE + '/users';
        });
    });
</script>

</body>
</html>